<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	/**
	 * Initialize the document type to XHTML1_STRICT within the view helper.
	 */
    protected function _initDoctype ()
    {
        $this->bootstrap('view');
        
        $view = $this->getResource('view');
        $view->doctype('XHTML1_STRICT');
    }
    /**
     * Initialize the locale to use.
     */
    protected function _initLocale ()
    {
		Zend_Registry::set('locale',
			new Zend_Locale('nl_NL')
		);
    }
	/**
	 * Initialize a Zend_Session_Namespace object, store this object within the global Zend_Registry underneath the
	 * "session" key.
	 */
    protected function _initSession ()
    {
		Zend_Registry::set('session', new Zend_Session_Namespace('Bwab'));
    }
    /**
     * Initialize the Zend_Cache object, store this object within the global Zend_Registry underneath the "cache" key.
     */
    protected function _initCache ()
    {
		$frontendOptions 	= array('automatic_serialization' => true);
    	$backendOptions  	= array('cache_dir' => sys_get_temp_dir());

    	Zend_Registry::set('cache',
    		Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions)
    	);
    }

    /**
     * Initialize the Factories used.
     */
    protected function _initFactories ()
    {
    	// configure Factory Registry with concrete domainFactory instance
    	$domainFactory = new Application_Model_Factory_Domain();
		Application_Model_Factory_Registry::setDomainFactory($domainFactory);

		// configure Factory Registry with concrete dbTableFactory instance
		$dbTableFactory = new Application_Model_Factory_DbTable();
		Application_Model_Factory_Registry::setDbTableFactory($dbTableFactory);

		// configure Factory Registry with concrete mapperFactory instance
		$mapperFactory = new Application_Model_Factory_Mapper_DbTable();
		$mapperFactory->setDomainFactory($domainFactory);
		$mapperFactory->setDbTableFactory($dbTableFactory);
		
		Application_Model_Factory_Registry::setMapperFactory($mapperFactory);
    }
    
    protected function _initRoutes()
    {
    	
    	$frontController = Zend_Controller_Front::getInstance();
		
    	
    	
    	
		$frontController->getRouter()->addRoute('queryparam_page',
			new Zend_Controller_Router_Route(':content/:controller/:action/:queryparam',
				array(
					'module'	=> 'thesis',
					'content' => 'page',
					'action' => 'index',
					'queryparam' => ''
				)
			)
		);
		
		$frontController->getRouter()->addRoute('topicsparam_page',
			new Zend_Controller_Router_Route(':content/:controller/:action/:queryparam/:topicparam',
				array(
					'module'	=> 'thesis',
					'content' => 'page',
					'action' => 'index',
					'queryparam' => '',
					'topicparam' => ''
				)
			)
		);
		
		$frontController->getRouter()->addRoute('content_page',
			new Zend_Controller_Router_Route('/page/:controller/:queryparam',
				array(
					'module'	=> 'thesis',
					'content' => 'page',
					'controller' => 'author',
					'action' => 'index',
					'queryparam' => ''
				)
			)
		);

		$frontController->getRouter()->addRoute('overview',
			new Zend_Controller_Router_Route('page/:controller/overview',
				array(
					'module'	=> 'thesis',
					'content' => 'page',
					'controller' => 'author',
					'action' => 'overview'
				)
			)
		);
		
		$frontController->getRouter()->addRoute('content_negotiation',
			new Zend_Controller_Router_Route('resource/*',
				array(
					'module' => 'thesis',
					'controller' => 'resource',
					'action' => 'redirect'
				)
			)
		);
		
//		$frontController->getRouter()->addRoute('thesis_search',
//			new Zend_Controller_Router_Route('/thesis/search/*',
//				array(
//					'module'	=> 'thesis',
//					'controller' => 'search'
//				)
//			)
//		);
    }
    
}